home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / internet / sweeper / samples / olecon~1 / include / proppage.h < prev    next >
Text File  |  1995-11-25  |  5KB  |  133 lines

  1. //=--------------------------------------------------------------------------=
  2. // PropertyPages.H
  3. //=--------------------------------------------------------------------------=
  4. // Copyright  1995  Microsoft Corporation.  All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // class declaration for CPropertyPage.
  13. //
  14. #ifndef _PROPERTYPAGES_H_
  15.  
  16. // things we really need
  17. //
  18. #include "Unknown.H"
  19. #include <olectl.h>
  20. #include "LocalSrv.H"
  21.  
  22. //=--------------------------------------------------------------------------=
  23. // messages that we'll send to property pages to instruct them to accomplish
  24. // tasks.
  25. //
  26. #define PPM_NEWOBJECTS    (WM_USER + 100)
  27. #define PPM_APPLY         (WM_USER + 101)
  28. #define PPM_EDITPROPERTY  (WM_USER + 102)
  29.  
  30.  
  31. //=--------------------------------------------------------------------------=
  32. // structure that control writers will use to define property pages.
  33. //
  34. typedef struct tagPROPERTYPAGEINFO {
  35.  
  36.     UNKNOWNOBJECTINFO unknowninfo;
  37.     WORD    wDlgResourceId;
  38.     WORD    wTitleId;
  39.     WORD    wDocStringId;
  40.     LPSTR   szHelpFile;
  41.     DWORD   dwHelpContextId;
  42.  
  43. } PROPERTYPAGEINFO;
  44.  
  45. #ifndef INITOBJECTS
  46.  
  47. #define DEFINE_PROPERTYPAGEOBJECT(name, pclsid, pszon, pfn, wr, wt, wd, pszhf, dwhci) \
  48.     extern PROPERTYPAGEINFO name##Page \
  49.  
  50. #else // INITOBJECTS
  51.  
  52. #define DEFINE_PROPERTYPAGEOBJECT(name, pclsid, pszon, pfn, wr, wt, wd, pszhf, dwhci) \
  53.     PROPERTYPAGEINFO name##Page = { {pclsid, pszon, pfn }, wr, wt, wd, pszhf, dwhci } \
  54.  
  55. #endif // INITOBJECTS
  56.  
  57.  
  58. #define TEMPLATENAMEOFPROPPAGE(index)    MAKEINTRESOURCE(((PROPERTYPAGEINFO *)(g_ObjectInfo[index].pInfo))->wDlgResourceId)
  59. #define TITLEIDOFPROPPAGE(index)         (((PROPERTYPAGEINFO *)(g_ObjectInfo[index].pInfo))->wTitleId)
  60. #define DOCSTRINGIDOFPROPPAGE(index)     (((PROPERTYPAGEINFO *)(g_ObjectInfo[index].pInfo))->wDocStringId)
  61. #define HELPCONTEXTOFPROPPAGE(index)     (((PROPERTYPAGEINFO *)(g_ObjectInfo[index].pInfo))->dwHelpContextId)
  62. #define HELPFILEOFPROPPAGE(index)        (((PROPERTYPAGEINFO *)(g_ObjectInfo[index].pInfo))->szHelpFile)
  63.  
  64. //=--------------------------------------------------------------------------=
  65. //
  66. class CPropertyPage : public CUnknownObject, public IPropertyPage2 {
  67.  
  68.   public:
  69.     // IUnknown methods
  70.     //
  71.     DECLARE_STANDARD_UNKNOWN();
  72.  
  73.     // IPropertyPage methods
  74.     //
  75.     STDMETHOD(SetPageSite)(LPPROPERTYPAGESITE pPageSite);
  76.     STDMETHOD(Activate)(HWND hwndParent, LPCRECT lprc, BOOL bModal);
  77.     STDMETHOD(Deactivate)(void);
  78.     STDMETHOD(GetPageInfo)(LPPROPPAGEINFO pPageInfo);
  79.     STDMETHOD(SetObjects)(ULONG cObjects, LPUNKNOWN FAR* ppunk);
  80.     STDMETHOD(Show)(UINT nCmdShow);
  81.     STDMETHOD(Move)(LPCRECT prect);
  82.     STDMETHOD(IsPageDirty)(void);
  83.     STDMETHOD(Apply)(void);
  84.     STDMETHOD(Help)(LPCOLESTR lpszHelpDir);
  85.     STDMETHOD(TranslateAccelerator)(LPMSG lpMsg);
  86.  
  87.     // IPropertyPage2 methods
  88.     //
  89.     STDMETHOD(EditProperty)(THIS_ DISPID dispid);
  90.  
  91.     // constructor destructor
  92.     //
  93.     CPropertyPage(IUnknown *pUnkOuter, int iObjectType);
  94.     virtual ~CPropertyPage();
  95.  
  96.     HINSTANCE GetResourceHandle(void);            // returns current resource handle.
  97.  
  98.   protected:
  99.     IPropertyPageSite *m_pPropertyPageSite;       // pointer to our ppage site.
  100.     void     MakeDirty();                         // makes the property page dirty.
  101.     HWND     m_hwnd;                              // our hwnd.
  102.  
  103.     // the following two methods allow a property page implementer to get at all the
  104.     // objects that we need to set here.
  105.     //
  106.     IUnknown *FirstControl(DWORD *dwCookie);
  107.     IUnknown *NextControl(DWORD *dwCookie);
  108.  
  109.   private:
  110.     IUnknown **m_ppUnkObjects;                    // objects that we're working with.
  111.  
  112.     unsigned m_fActivated:1;
  113.     unsigned m_fDirty:1;
  114.     int      m_ObjectType;                        // what type of object we are
  115.     UINT     m_cObjects;                          // how many objects we're holding on to
  116.  
  117.     void     m_ReleaseAllObjects(void);           // clears out all objects we've got.
  118.     HRESULT  m_EnsureLoaded(void);                // forces the load of the page.
  119.  
  120.     virtual HRESULT InternalQueryInterface(REFIID, void **);
  121.  
  122.     // default dialog proc for a page.
  123.     //
  124.     static BOOL CALLBACK PropPageDlgProc(HWND, UINT, WPARAM, LPARAM);
  125.  
  126.     // all page implementers MUST implement the following function.
  127.     //
  128.     virtual BOOL DialogProc(HWND, UINT, WPARAM, LPARAM) PURE;
  129. };
  130.  
  131. #define _PROPERTYPAGES_H_
  132. #endif // _PROPERTYPAGES_H_
  133.